#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>

void *doing(void *arg)
{
    for (size_t i = 0; i < 20; i++)
    {
        printf(" %s %ld \n", "-----sub thread ", i);
        sleep(1);
    }
    printf(" 子线程结束了 \n");
}
int main(int argc, char **argv)
{

    pthread_t tid;
    pthread_create(&tid, NULL, doing, NULL);
    for (size_t i = 0; i < 3; i++)
    {
        printf(" %s %ld \n", "main thread ", i);
        sleep(1);
    }
    printf(" 主线程结束了 \n");
    pthread_exit(NULL);
    

    return 0;
}